home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / skydiver.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  12KB  |  391 lines

  1. /***************************************************************************
  2.  
  3. Atari Sky Diver Driver
  4.  
  5. Memory Map:
  6. 0000-00FF    R/W    PAGE ZERO RAM
  7. 0010         R/W    H POS PLANE 1
  8. 0011         R/W    H POS PLANE 2
  9. 0012         R/W    H POS MAN 1
  10. 0013         R/W    H POS MAN 2
  11. 0014         R/W    RANGE LOAD
  12. 0015         R/W    NOTE LOAD
  13. 0016         R/W    NAM LD
  14. 0017         R/W    UNUSED
  15. 0018         R/W    V POS PLANE 1
  16. 0019         R/W    PICTURE PLANE 1
  17. 001A         R/W    V POS PLANE 2
  18. 001B         R/W    PICTURE PLANE 2
  19. 001C         R/W    V POS MAN 1
  20. 001D         R/W    PICTURE MAN 1
  21. 001E         R/W    V POS MAN 2
  22. 001F         R/W    PICTURE MAN 2
  23. 0400-077F    R/W    PLAYFIELD
  24. 0780-07FF    R/W    MAPS TO 0000-D0
  25. 0800-0801     W     S LAMP
  26. 0802-0803     W     K LAMP
  27. 0804-0805     W     START LITE 1
  28. 0806-0807     W     START LITE 2
  29. 0808-0809     W     Y LAMP
  30. 080A-080B     W     D LAMP
  31. 080C-080D     W     SOUND ENABLE
  32. 1000-1001     W     JUMP LITE 1
  33. 1002-1003     W     COIN LOCK OUT
  34. 1006-1007     W     JUMP LITE 2
  35. 1008-1009     W     WHISTLE
  36. 100A-100B     W     WHISTLE 2
  37. 100C-100D     W     NMION
  38. 100E-100F     W     WIDTH
  39. 1800          R     D6=LEFT 1, D7=RIGHT 1
  40. 1801          R     D6=LEFT 2, D7=RIGHT 2
  41. 1802          R     D6=JUMP 1, D7=CHUTE 1
  42. 1803          R     D6=JUMP 2, D7=CHUTE 2
  43. 1804          R     D6=(D) OPT SW: NEXT TEST, D7=(F) OPT SW
  44. 1805          R     D6=(E) OPT SW, D7= (H) OPT SW: DIAGNOSTICS
  45. 1806          R     D6=START 1, D7=COIN 1
  46. 1807          R     D6=START 2, D7=COIN 2
  47. 1808          R     D6=MISSES 2, D7=MISSES 1
  48. 1809          R     D6=COIN 2, D7=COIN1
  49. 180A          R     D6=HARD/EASY, D7=EXTENDED PLAY
  50. 180B          R     D6=LANGUAGE 2, D7=LANGUAGE 1
  51. 1810          R     D6=TEST, D7=!VBLANK
  52. 1811          R     D6=!SLAM, D7=UNUSED
  53. 2000          W     TIMER RESET
  54. 2002-2003     W     I LAMP
  55. 2004-2005     W     V LAMP
  56. 2006-2007     W     E LAMP
  57. 2008-2009     W     R LAMP
  58. 200A-200B     W     OCT 1
  59. 200C-200D     W     OCT 2
  60. 200E-200F     W     NOISE RESET
  61. 2800-2FFF     R     ROM 0
  62. 3000-37FF     R     ROM 1
  63. 3800-3FFF     R     ROM 2A
  64. 7800-7FFF     R     ROM 2B
  65.  
  66. If you have any questions about how this driver works, don't hesitate to
  67. ask.  - Mike Balfour (mab22@po.cwru.edu)
  68.  
  69. Notes:
  70.  
  71. The NMI interrupts are only used to read the coin switches.
  72.  
  73. ***************************************************************************/
  74.  
  75. #include "driver.h"
  76. #include "vidhrdw/generic.h"
  77.  
  78. /* vidhrdw/skydiver.c */
  79. WRITE_HANDLER( skydiver_sk_lamps_w );
  80. WRITE_HANDLER( skydiver_yd_lamps_w );
  81. WRITE_HANDLER( skydiver_iver_lamps_w );
  82. WRITE_HANDLER( skydiver_width_w );
  83. extern void skydiver_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  84.  
  85. static int skydiver_nmion;
  86.  
  87. READ_HANDLER( skydiver_input_0_r )
  88. {
  89.     int data = input_port_0_r(0);
  90.  
  91.     switch(offset)
  92.     {
  93.         case 0:        return ((data & 0x03) << 6);
  94.         case 1:        return ((data & 0x0C) << 4);
  95.         case 2:        return ((data & 0x30) << 2);
  96.         case 3:        return ((data & 0xC0) << 0);
  97.         default:        return 0;
  98.     }
  99. }
  100.  
  101. READ_HANDLER( skydiver_input_1_r )
  102. {
  103.     int data = input_port_1_r(0);
  104.  
  105.     switch(offset)
  106.     {
  107.         case 0:        return ((data & 0x03) << 6);
  108.         case 1:        return ((data & 0x0C) << 4);
  109.         case 2:        return ((data & 0x30) << 2);
  110.         case 3:        return ((data & 0xC0) << 0);
  111.         default:        return 0;
  112.     }
  113. }
  114.  
  115. READ_HANDLER( skydiver_input_2_r )
  116. {
  117.     int data = input_port_2_r(0);
  118.  
  119.     switch(offset)
  120.     {
  121.         case 0:        return ((data & 0x03) << 6);
  122.         case 1:        return ((data & 0x0C) << 4);
  123.         case 2:        return ((data & 0x30) << 2);
  124.         case 3:        return ((data & 0xC0) << 0);
  125.         default:        return 0;
  126.     }
  127. }
  128.  
  129. READ_HANDLER( skydiver_input_3_r )
  130. {
  131.     int data = input_port_3_r(0);
  132.  
  133.     switch(offset)
  134.     {
  135.         case 0:        return ((data & 0x03) << 6);
  136.         case 1:        return ((data & 0x0C) << 4);
  137.         case 2:        return ((data & 0x30) << 2);
  138.         case 3:        return ((data & 0xC0) << 0);
  139.         default:        return 0;
  140.     }
  141. }
  142.  
  143. WRITE_HANDLER( skydiver_nmion_w )
  144. {
  145. //    logerror("nmi_on: %02x:%02x\n", offset, data);
  146.     skydiver_nmion = offset;
  147. }
  148.  
  149. int skydiver_interrupt(void)
  150. {
  151.     if (skydiver_nmion)
  152.         return nmi_interrupt();
  153.     else
  154.            return ignore_interrupt();
  155. }
  156.  
  157. static struct MemoryReadAddress readmem[] =
  158. {
  159.     { 0x0000, 0x00ff, MRA_RAM },
  160.     { 0x0400, 0x077f, MRA_RAM },
  161. //  { 0x780, 0x7ff, MRA_RAM },
  162.     { 0x1800, 0x1803, skydiver_input_0_r },
  163.     { 0x1804, 0x1807, skydiver_input_1_r },
  164.     { 0x1808, 0x180b, skydiver_input_2_r },
  165.     { 0x1810, 0x1811, skydiver_input_3_r },
  166.     { 0x2000, 0x2000, watchdog_reset_r },
  167.     { 0x2800, 0x3fff, MRA_ROM },
  168.     { 0x7800, 0x7fff, MRA_ROM },
  169.     { 0xf800, 0xffff, MRA_ROM },
  170.     { -1 }    /* end of table */
  171. };
  172.  
  173. static struct MemoryWriteAddress writemem[] =
  174. {
  175.     { 0x0000, 0x00ff, MWA_RAM },
  176.     { 0x0010, 0x001f, MWA_RAM, &spriteram, &spriteram_size },
  177.     { 0x0400, 0x077f, videoram_w, &videoram, &videoram_size },
  178.     // { 0x0780, 0x07ff, MWA_RAM },
  179.     { 0x0800, 0x0803, skydiver_sk_lamps_w },
  180.     // { 0x0804, 0x0807, skydiver_start_lamps_w },
  181.     { 0x0808, 0x080b, skydiver_yd_lamps_w },
  182.     // { 0x080c, 0x080d, skydiver_sound_enable_w },
  183.     // { 0x1000, 0x1001, skydiver_jump1_lamps_w },
  184.     // { 0x1002, 0x1003, skydiver_coin_lockout_w },
  185.     // { 0x1006, 0x1007, skydiver_jump2_lamps_w },
  186.     // { 0x1008, 0x100b, skydiver_whistle_w },
  187.     { 0x100c, 0x100d, skydiver_nmion_w },
  188.     { 0x100e, 0x100f, skydiver_width_w },
  189.     { 0x2002, 0x2009, skydiver_iver_lamps_w },
  190.     // { 0x200a, 0x200d, skydiver_oct_w },
  191.     // { 0x200e, 0x200f, skydiver_noise_reset_w },
  192.     { 0x2800, 0x3fff, MWA_ROM },
  193.     { -1 }    /* end of table */
  194. };
  195.  
  196. INPUT_PORTS_START( skydiver )
  197.     PORT_START /* fake port, gets mapped to Sky Diver ports */
  198.     PORT_BIT (0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )
  199.     PORT_BIT (0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT )
  200.     PORT_BIT (0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_PLAYER2 )
  201.     PORT_BIT (0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER2 )
  202.     PORT_BIT (0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )    /* Jump 1 */
  203.     PORT_BIT (0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )    /* Chute 1 */
  204.     PORT_BIT (0x40, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )    /* Jump 2 */
  205.     PORT_BIT (0x80, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )    /* Chute 2 */
  206.  
  207.     PORT_START        /* fake port, gets mapped to Sky Diver ports */
  208.     PORT_BITX(0x01, IP_ACTIVE_LOW, IPT_UNKNOWN, "(D) OPT SW NEXT TEST", KEYCODE_D, IP_JOY_NONE )
  209.     PORT_BITX(0x02, IP_ACTIVE_LOW, IPT_UNKNOWN, "(F) OPT SW", KEYCODE_F, IP_JOY_NONE )
  210.     PORT_BITX(0x04, IP_ACTIVE_LOW, IPT_UNKNOWN, "(E) OPT SW", KEYCODE_E, IP_JOY_NONE )
  211.     PORT_BITX(0x08, IP_ACTIVE_LOW, IPT_UNKNOWN, "(H) OPT SW DIAGNOSTICS", KEYCODE_H, IP_JOY_NONE )
  212.     PORT_BIT (0x10, IP_ACTIVE_LOW, IPT_START1 )
  213.     PORT_BIT_IMPULSE( 0x20, IP_ACTIVE_LOW, IPT_COIN1, 1 )
  214.     PORT_BIT (0x40, IP_ACTIVE_LOW, IPT_START2 )
  215.     PORT_BIT_IMPULSE( 0x80, IP_ACTIVE_LOW, IPT_COIN2, 1 )
  216.  
  217.     PORT_START        /* fake port, gets mapped to Sky Diver ports */
  218.     PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) )
  219.     PORT_DIPSETTING(    0x00, "3" )
  220.     PORT_DIPSETTING(    0x01, "4" )
  221.     PORT_DIPSETTING(    0x02, "5" )
  222.     PORT_DIPSETTING(    0x03, "6" )
  223.     PORT_DIPNAME( 0x0c, 0x08, DEF_STR( Coinage ) )
  224.     PORT_DIPSETTING(    0x0c, DEF_STR( 2C_1C ) )
  225.     PORT_DIPSETTING(    0x08, DEF_STR( 1C_1C ) )
  226.     PORT_DIPSETTING(    0x04, DEF_STR( 1C_2C ) )
  227.     PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
  228.     PORT_DIPNAME( 0x10, 0x00, DEF_STR( Difficulty ) )
  229.     PORT_DIPSETTING(    0x10, "Easy" )
  230.     PORT_DIPSETTING(    0x00, "Hard" )
  231.     PORT_DIPNAME( 0x20, 0x00, "Extended Play" )
  232.     PORT_DIPSETTING(    0x20, DEF_STR( No ) )
  233.     PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
  234.     PORT_DIPNAME( 0xc0, 0x00, "Language" )
  235.     PORT_DIPSETTING(    0x00, "English" )
  236.     PORT_DIPSETTING(    0x40, "French" )
  237.     PORT_DIPSETTING(    0x80, "Spanish" )
  238.     PORT_DIPSETTING(    0xc0, "German" )
  239.  
  240.     PORT_START        /* fake port, gets mapped to Sky Diver ports */
  241.     PORT_BITX(0x01, IP_ACTIVE_LOW, IPT_SERVICE | IPF_TOGGLE, "Self Test", KEYCODE_F2, IP_JOY_NONE )
  242.     PORT_BIT (0x02, IP_ACTIVE_LOW, IPT_VBLANK )
  243.     PORT_BIT (0x04, IP_ACTIVE_LOW, IPT_TILT )
  244.     PORT_BIT (0xF8, IP_ACTIVE_HIGH, IPT_UNUSED )
  245.  
  246. INPUT_PORTS_END
  247.  
  248.  
  249. static struct GfxLayout charlayout =
  250. {
  251.     8,8,    /* 8*8 characters */
  252.     64,     /* 64 characters */
  253.     1,        /* 1 bit per pixel */
  254.     { 0 },          /* no separation in 1 bpp */
  255.     { 7, 6, 5, 4, 15, 14, 13, 12 },
  256.     { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
  257.     8*16 /* every char takes 16 consecutive bytes */
  258. };
  259.  
  260. static struct GfxLayout motion_layout =
  261. {
  262.     16,16,    /* 16*16 characters */
  263.     32,     /* 32 characters */
  264.     1,        /* 1 bit per pixel */
  265.     { 0 },          /* no separation in 1 bpp */
  266.     { 4, 5, 6, 7, 4 + 0x400*8, 5 + 0x400*8, 6 + 0x400*8, 7 + 0x400*8,
  267.       12, 13, 14, 15, 12 + 0x400*8, 13 + 0x400*8, 14 + 0x400*8, 15 + 0x400*8 },
  268.     { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
  269.       8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 },
  270.     8*32 /* every char takes 32 consecutive bytes */
  271. };
  272.  
  273. static struct GfxLayout wide_motion_layout =
  274. {
  275.     32,16,    /* 32*16 characters */
  276.     32,     /* 32 characters */
  277.     1,        /* 1 bit per pixel */
  278.     { 0 },          /* no separation in 1 bpp */
  279.     { 4, 4, 5, 5, 6, 6, 7, 7,
  280.       4 + 0x400*8, 4 + 0x400*8, 5 + 0x400*8, 5 + 0x400*8,
  281.       6 + 0x400*8, 6 + 0x400*8, 7 + 0x400*8, 7 + 0x400*8,
  282.       12, 12, 13, 13, 14, 14, 15, 15,
  283.       12 + 0x400*8, 12 + 0x400*8, 13 + 0x400*8, 13 + 0x400*8,
  284.       14 + 0x400*8, 14 + 0x400*8, 15 + 0x400*8, 15 + 0x400*8 },
  285.     { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
  286.       8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 },
  287.     8*32 /* every char takes 32 consecutive bytes */
  288. };
  289.  
  290. static struct GfxDecodeInfo gfxdecodeinfo[] =
  291. {
  292.     { REGION_GFX1, 0, &charlayout,         0, 6 },
  293.     { REGION_GFX2, 0, &motion_layout,      0, 6 },
  294.     { REGION_GFX2, 0, &wide_motion_layout, 0, 6 },
  295.     { -1 } /* end of array */
  296. };
  297.  
  298. #if 0
  299. static unsigned char palette[] =
  300. {
  301.     0x00,0x00,0x00, /* BLACK */
  302.     0xff,0xff,0xff, /* WHITE */
  303.     0x80,0x80,0x80, /* GREY */
  304. };
  305. #else
  306. static unsigned char palette[] =
  307. {
  308.     0x00,0x00,0x00, /* BLACK */
  309.     0xbf,0xbf,0xff, /* LT BLUE */
  310.     0x7f,0x7f,0xff, /* BLUE */
  311. };
  312. #endif
  313.  
  314. static unsigned short colortable[] =
  315. {
  316.     0x02, 0x01,
  317.     0x02, 0x00,
  318.     0x01, 0x02,
  319.     0x00, 0x02,
  320.     0x00, 0x00, /* used only to draw the SKYDIVER LEDs */
  321.     0x00, 0x01, /* used only to draw the SKYDIVER LEDs */
  322. };
  323. static void init_palette(unsigned char *game_palette, unsigned short *game_colortable,const unsigned char *color_prom)
  324. {
  325.     memcpy(game_palette,palette,sizeof(palette));
  326.     memcpy(game_colortable,colortable,sizeof(colortable));
  327. }
  328.  
  329.  
  330. static struct MachineDriver machine_driver_skydiver =
  331. {
  332.     /* basic machine hardware */
  333.     {
  334.         {
  335.             CPU_M6800,
  336.             3000000/4,       /* ???? */
  337.             readmem,writemem,0,0,
  338.             skydiver_interrupt,8
  339.         }
  340.     },
  341.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  342.     1,    /* single CPU, no need for interleaving */
  343.     0,
  344.  
  345.     /* video hardware */
  346.     32*8, 32*8, { 0*8, 32*8-1, 0*8, 29*8-1 },
  347.     gfxdecodeinfo,
  348.     sizeof(palette) / sizeof(palette[0]) / 3, sizeof(colortable) / sizeof(colortable[0]),
  349.     init_palette,
  350.  
  351.     VIDEO_TYPE_RASTER,
  352.     0,
  353.     generic_vh_start,
  354.     generic_vh_stop,
  355.     skydiver_vh_screenrefresh,
  356.  
  357.     /* sound hardware */
  358.     0,0,0,0
  359.  
  360. };
  361.  
  362.  
  363.  
  364.  
  365.  
  366. /***************************************************************************
  367.  
  368.   Game ROMs
  369.  
  370. ***************************************************************************/
  371.  
  372. ROM_START( skydiver )
  373.     ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */
  374.     ROM_LOAD( "33167-02.f1", 0x2800, 0x0800, 0x25a5c976 )
  375.     ROM_LOAD( "33164-02.e1", 0x3000, 0x0800, 0xa348ac39 )
  376.     ROM_LOAD( "33165-02.d1", 0x3800, 0x0800, 0xa1fc5504 )
  377.     ROM_LOAD( "33166-02.c1", 0x7800, 0x0800, 0x3d26da2b )
  378.     ROM_RELOAD(              0xF800, 0x0800 )
  379.  
  380.     ROM_REGION( 0x0400, REGION_GFX1 | REGIONFLAG_DISPOSE )
  381.     ROM_LOAD( "33163-01.h5", 0x0000, 0x0400, 0x5b9bb7c2 )
  382.  
  383.     ROM_REGION( 0x0800, REGION_GFX2 | REGIONFLAG_DISPOSE )
  384.     ROM_LOAD( "33176-01.l5", 0x0000, 0x0400, 0x6b082a01 )
  385.     ROM_LOAD( "33177-01.k5", 0x0400, 0x0400, 0xf5541af0 )
  386. ROM_END
  387.  
  388.  
  389.  
  390. GAMEX( 1978, skydiver, 0, skydiver, skydiver, 0, ROT0, "Atari", "Sky Diver", GAME_NO_SOUND )
  391.